//获取openid 和手机号
export const getPhoneApi = async () => {
	const r = await wx.login()
	const key = uni.getStorageSync('ylProject').miniKey
	const {
		data: res
	} = await uni.$http.get('/api/auth/getLoginInfo', {
		code: r.code,
		key
	})
	return res
}

//用户token
export const getTokenApi = async (openId, phone, spreadCode) => {
	const key = uni.getStorageSync('ylProject').miniKey
	const {
		data: res
	} = await uni.$http.post(`/api/auth/wxLogin`, {
		miniKey: key,
		openId,
		phone,
		register: true,
		spreadCode,
		type: "1"
	})
	return res
}

//根据id获取用户信息
export const getUserApi = async (id) => {
	const {
		data: res
		// } = await uni.$http.post(`/api/auth/getUserInfo`)
	} = await uni.$http.post(`/api/miniApp/querySingleDetail/${id}`)
	return res
}

//获取用户协议 
export const getAgreementApi = async (key) => {
	const {
		data: res
	} = await uni.$http.get(`/api/miniApp/getAgreement/${key}`)
	return res
}

// 用户进入、退出小程序埋点
export const joinOrOutAppApi = async (type) => {
	const {
		data: res
	} = await uni.$http.post(`/api/miniApp/joinOrOutApp/${type}`)
	return res
}
